﻿namespace Stickam_Client
{
    public __gc class UserlistClass
    {
        // Methods
        public: UserlistClass(Form1 __gc* ParentForm)
        {
            this->FormParent = ParentForm;
        }

        public: void __gc* add(String __gc* newUserID, String __gc* newID, String __gc* newUserName, String __gc* newScreenName, Boolean __gc* newIsVideo, Boolean __gc* newIsModerator, Boolean __gc* newIsOwner, String __gc* newUserType, String __gc* newSessionType, String __gc* newLangID, String __gc* newComponentBit)
        {
            Int32 __gc* index = Array::IndexOf<String __gc*>(this->Array_userID, newUserID);
            if (index == -1)
            {
                this->Array_componentBit = *static_cast<__box String __gc* __gc []*>(Utils::CopyArray(*static_cast<__box Array*>(this->Array_componentBit), __gc new String __gc*[(this->total + 1)]));
                this->Array_font = *static_cast<__box String __gc* __gc []*>(Utils::CopyArray(*static_cast<__box Array*>(this->Array_font), __gc new String __gc*[(this->total + 1)]));
                this->Array_fontBold = *static_cast<__box Boolean __gc* __gc []*>(Utils::CopyArray(*static_cast<__box Array*>(this->Array_fontBold), __gc new Boolean __gc*[(this->total + 1)]));
                this->Array_fontColor = *static_cast<__box String __gc* __gc []*>(Utils::CopyArray(*static_cast<__box Array*>(this->Array_fontColor), __gc new String __gc*[(this->total + 1)]));
                this->Array_fontItalics = *static_cast<__box Boolean __gc* __gc []*>(Utils::CopyArray(*static_cast<__box Array*>(this->Array_fontItalics), __gc new Boolean __gc*[(this->total + 1)]));
                this->Array_fontSize = *static_cast<__box Int32 __gc* __gc []*>(Utils::CopyArray(*static_cast<__box Array*>(this->Array_fontSize), __gc new Int32 __gc*[(this->total + 1)]));
                this->Array_fontUnderline = *static_cast<__box Boolean __gc* __gc []*>(Utils::CopyArray(*static_cast<__box Array*>(this->Array_fontUnderline), __gc new Boolean __gc*[(this->total + 1)]));
                this->Array_id = *static_cast<__box String __gc* __gc []*>(Utils::CopyArray(*static_cast<__box Array*>(this->Array_id), __gc new String __gc*[(this->total + 1)]));
                this->Array_isIgnored = *static_cast<__box Boolean __gc* __gc []*>(Utils::CopyArray(*static_cast<__box Array*>(this->Array_isIgnored), __gc new Boolean __gc*[(this->total + 1)]));
                this->Array_isModerator = *static_cast<__box Boolean __gc* __gc []*>(Utils::CopyArray(*static_cast<__box Array*>(this->Array_isModerator), __gc new Boolean __gc*[(this->total + 1)]));
                this->Array_isOwner = *static_cast<__box Boolean __gc* __gc []*>(Utils::CopyArray(*static_cast<__box Array*>(this->Array_isOwner), __gc new Boolean __gc*[(this->total + 1)]));
                this->Array_isVideo = *static_cast<__box Boolean __gc* __gc []*>(Utils::CopyArray(*static_cast<__box Array*>(this->Array_isVideo), __gc new Boolean __gc*[(this->total + 1)]));
                this->Array_langID = *static_cast<__box String __gc* __gc []*>(Utils::CopyArray(*static_cast<__box Array*>(this->Array_langID), __gc new String __gc*[(this->total + 1)]));
                this->Array_screenName = *static_cast<__box String __gc* __gc []*>(Utils::CopyArray(*static_cast<__box Array*>(this->Array_screenName), __gc new String __gc*[(this->total + 1)]));
                this->Array_sessionType = *static_cast<__box String __gc* __gc []*>(Utils::CopyArray(*static_cast<__box Array*>(this->Array_sessionType), __gc new String __gc*[(this->total + 1)]));
                this->Array_userID = *static_cast<__box String __gc* __gc []*>(Utils::CopyArray(*static_cast<__box Array*>(this->Array_userID), __gc new String __gc*[(this->total + 1)]));
                this->Array_userName = *static_cast<__box String __gc* __gc []*>(Utils::CopyArray(*static_cast<__box Array*>(this->Array_userName), __gc new String __gc*[(this->total + 1)]));
                this->Array_userType = *static_cast<__box String __gc* __gc []*>(Utils::CopyArray(*static_cast<__box Array*>(this->Array_userType), __gc new String __gc*[(this->total + 1)]));
                index = this->total;
                this->total++;
                this->Array_font[index] = S"Arial";
                this->Array_fontBold[index] = false;
                this->Array_fontColor[index] = S"000000";
                this->Array_fontItalics[index] = false;
                this->Array_fontSize[index] = 12;
                this->Array_fontUnderline[index] = false;
                this->Array_isIgnored[index] = false;
            }
            else
            {
                this->RemoveUsername(this->Array_screenName[index]);
                this->FormParent->UserlistCtl->Nodes->RemoveByKey(newUserID);
            }
            this->Array_componentBit[index] = newComponentBit;
            this->Array_id[index] = newID;
            this->Array_isModerator[index] = newIsModerator;
            this->Array_isOwner[index] = newIsOwner;
            this->Array_isVideo[index] = newIsVideo;
            this->Array_langID[index] = newLangID;
            this->Array_screenName[index] = newScreenName;
            this->Array_sessionType[index] = newSessionType;
            this->Array_userID[index] = newUserID;
            this->Array_userName[index] = newUserName;
            this->Array_userType[index] = newUserType;
            String __gc* imageKey = S"user_reg";
            if (newIsVideo)
            {
                imageKey = S"user_cam";
            }
            if (newIsModerator)
            {
                imageKey = S"user_mod";
            }
            if (newIsOwner)
            {
                imageKey = S"user_host";
            }
            if (newUserType == S"200")
            {
                imageKey = S"user_glb";
            }
            this->Usernames = *static_cast<__box String __gc* __gc []*>(Utils::CopyArray(*static_cast<__box Array*>(this->Usernames), __gc new String __gc*[(this->Usernames->Length + 1)]));
            this->Usernames[(this->Usernames->Length - 1)] = newScreenName;
            Array::Sort<String __gc*>(this->Usernames);
            Int32 __gc* num2 = (Array::IndexOf<String __gc*>(this->Usernames, newScreenName) - 1);
            this->FormParent->UserlistCtl->Nodes->Insert(num2, newUserID, newScreenName, imageKey, imageKey);
        }

        public: void __gc* clear()
        {
            this->total = 0;
            this->Array_componentBit = __gc new String __gc*[1];
            this->Array_font = __gc new String __gc*[1];
            this->Array_fontBold = __gc new Boolean __gc*[1];
            this->Array_fontColor = __gc new String __gc*[1];
            this->Array_fontItalics = __gc new Boolean __gc*[1];
            this->Array_fontSize = __gc new Int32 __gc*[1];
            this->Array_fontUnderline = __gc new Boolean __gc*[1];
            this->Array_id = __gc new String __gc*[1];
            this->Array_isIgnored = __gc new Boolean __gc*[1];
            this->Array_isModerator = __gc new Boolean __gc*[1];
            this->Array_isOwner = __gc new Boolean __gc*[1];
            this->Array_isVideo = __gc new Boolean __gc*[1];
            this->Array_langID = __gc new String __gc*[1];
            this->Array_screenName = __gc new String __gc*[1];
            this->Array_sessionType = __gc new String __gc*[1];
            this->Array_userID = __gc new String __gc*[1];
            this->Array_userName = __gc new String __gc*[1];
            this->Array_userType = __gc new String __gc*[1];
            this->Usernames = __gc new String __gc*[1];
            this->FormParent->UserlistCtl->Nodes->Clear();
        }

        public: Object __gc* getParam(String __gc* byUserID, Int32 __gc* paramType)
        {
            Int32 __gc* index = Array::IndexOf<String __gc*>(this->Array_userID, byUserID);
            if (index != -1)
            {
                return this->getParamByIndex(index, paramType);
            }
            return S"";
        }

        public: Object __gc* getParamByIndex(Int32 __gc* Index, Int32 __gc* paramType)
        {
            Int32 __gc* num = paramType;
            if (num == this->componentBit)
            {
                return this->Array_componentBit[Index];
            }
            if (num == this->font)
            {
                return this->Array_font[Index];
            }
            if (num == this->fontBold)
            {
                return this->Array_fontBold[Index];
            }
            if (num == this->fontColor)
            {
                return this->Array_fontColor[Index];
            }
            if (num == this->fontItalics)
            {
                return this->Array_fontItalics[Index];
            }
            if (num == this->fontSize)
            {
                return this->Array_fontSize[Index];
            }
            if (num == this->fontUnderline)
            {
                return this->Array_fontUnderline[Index];
            }
            if (num == this->id)
            {
                return this->Array_id[Index];
            }
            if (num == -(this->isIgnored > false))
            {
                return this->Array_isIgnored[Index];
            }
            if (num == this->isModerator)
            {
                return this->Array_isModerator[Index];
            }
            if (num == this->isOwner)
            {
                return this->Array_isOwner[Index];
            }
            if (num == this->isVideo)
            {
                return this->Array_isVideo[Index];
            }
            if (num == this->langID)
            {
                return this->Array_langID[Index];
            }
            if (num == this->screenName)
            {
                return this->Array_screenName[Index];
            }
            if (num == this->sessionType)
            {
                return this->Array_sessionType[Index];
            }
            if (num == this->userID)
            {
                return this->Array_userID[Index];
            }
            if (num == this->userName)
            {
                return this->Array_userName[Index];
            }
            if (num == this->userType)
            {
                return this->Array_userType[Index];
            }
            return S"";
        }

        public: Object __gc* getParamByScreenName(String __gc* byScreenName, Int32 __gc* paramType)
        {
            Int32 __gc* index = Array::IndexOf<String __gc*>(this->Array_screenName, byScreenName);
            if (index != -1)
            {
                return this->getParamByIndex(index, paramType);
            }
            return S"";
        }

        public: Object __gc* getParamByUserName(String __gc* byUserName, Int32 __gc* paramType)
        {
            Int32 __gc* index = Array::IndexOf<String __gc*>(this->Array_userName, byUserName);
            if (index != -1)
            {
                return this->getParamByIndex(index, paramType);
            }
            return S"";
        }

        public: void __gc* remove(String __gc* oldUserID)
        {
            Int32 __gc* index = Array::IndexOf<String __gc*>(this->Array_userID, oldUserID);
            if (index != -1)
            {
                this->RemoveUsername(this->Array_screenName[index]);
                Array::Clear(this->Array_componentBit, index, 1);
                Array::Clear(this->Array_font, index, 1);
                Array::Clear(this->Array_fontBold, index, 1);
                Array::Clear(this->Array_fontColor, index, 1);
                Array::Clear(this->Array_fontItalics, index, 1);
                Array::Clear(this->Array_fontSize, index, 1);
                Array::Clear(this->Array_fontUnderline, index, 1);
                Array::Clear(this->Array_id, index, 1);
                Array::Clear(this->Array_isIgnored, index, 1);
                Array::Clear(this->Array_isModerator, index, 1);
                Array::Clear(this->Array_isOwner, index, 1);
                Array::Clear(this->Array_isVideo, index, 1);
                Array::Clear(this->Array_langID, index, 1);
                Array::Clear(this->Array_screenName, index, 1);
                Array::Clear(this->Array_sessionType, index, 1);
                Array::Clear(this->Array_userID, index, 1);
                Array::Clear(this->Array_userName, index, 1);
                Array::Clear(this->Array_userType, index, 1);
            }
            this->FormParent->UserlistCtl->Nodes->RemoveByKey(oldUserID);
        }

        private: void __gc* RemoveUsername(String __gc* Username)
        {
            Int32 __gc* index = Array::IndexOf<String __gc*>(this->Usernames, Username);
            if (this->Usernames->Length > 2)
            {
                this->Usernames[index] = this->Usernames[(this->Usernames->Length - 1)];
            }
            this->Usernames = *static_cast<__box String __gc* __gc []*>(Utils::CopyArray(*static_cast<__box Array*>(this->Usernames), __gc new String __gc*[((this->Usernames->Length - 2) + 1)]));
        }

        public: void __gc* setIgnore(String __gc* curUserID, Boolean __gc* newIsIgnored)
        {
            Int32 __gc* index = Array::IndexOf<String __gc*>(this->Array_userID, curUserID);
            if (index != -1)
            {
                this->Array_isIgnored[index] = newIsIgnored;
            }
        }

        public: void __gc* updateFont(String __gc* curUserID, String __gc* newFont, String __gc* newFontColor, Int32 __gc* newFontSize, Boolean __gc* newIsBold, Boolean __gc* newIsItalics, Boolean __gc* newIsUnderline)
        {
            Int32 __gc* index = Array::IndexOf<String __gc*>(this->Array_userID, curUserID);
            if (index != -1)
            {
                this->Array_font[index] = newFont;
                this->Array_fontBold[index] = newIsBold;
                this->Array_fontColor[index] = newFontColor;
                this->Array_fontItalics[index] = newIsItalics;
                this->Array_fontSize[index] = newFontSize;
                this->Array_fontUnderline[index] = newIsUnderline;
            }
        }


        // Fields
        private: String __gc* Array_componentBit __gc [] = __gc new String __gc*[1];
        private: String __gc* Array_font __gc [] = __gc new String __gc*[1];
        private: Boolean __gc* Array_fontBold __gc [] = __gc new Boolean __gc*[1];
        private: String __gc* Array_fontColor __gc [] = __gc new String __gc*[1];
        private: Boolean __gc* Array_fontItalics __gc [] = __gc new Boolean __gc*[1];
        private: Int32 __gc* Array_fontSize __gc [] = __gc new Int32 __gc*[1];
        private: Boolean __gc* Array_fontUnderline __gc [] = __gc new Boolean __gc*[1];
        private: String __gc* Array_id __gc [] = __gc new String __gc*[1];
        private: Boolean __gc* Array_isIgnored __gc [] = __gc new Boolean __gc*[1];
        private: Boolean __gc* Array_isModerator __gc [] = __gc new Boolean __gc*[1];
        private: Boolean __gc* Array_isOwner __gc [] = __gc new Boolean __gc*[1];
        private: Boolean __gc* Array_isVideo __gc [] = __gc new Boolean __gc*[1];
        private: String __gc* Array_langID __gc [] = __gc new String __gc*[1];
        private: String __gc* Array_screenName __gc [] = __gc new String __gc*[1];
        private: String __gc* Array_sessionType __gc [] = __gc new String __gc*[1];
        private: String __gc* Array_userID __gc [] = __gc new String __gc*[1];
        private: String __gc* Array_userName __gc [] = __gc new String __gc*[1];
        private: String __gc* Array_userType __gc [] = __gc new String __gc*[1];
        public: Int32 __gc* componentBit = 10;
        public: Int32 __gc* font = 11;
        public: Int32 __gc* fontBold = 14;
        public: Int32 __gc* fontColor = 12;
        public: Int32 __gc* fontItalics = 15;
        public: Int32 __gc* fontSize = 13;
        public: Int32 __gc* fontUnderline = 0x10;
        private: Form1 __gc* FormParent;
        public: Int32 __gc* id = 1;
        public: Boolean __gc* isIgnored = true;
        public: Int32 __gc* isModerator = 5;
        public: Int32 __gc* isOwner = 6;
        public: Int32 __gc* isVideo = 4;
        public: Int32 __gc* langID = 9;
        public: Int32 __gc* screenName = 3;
        public: Int32 __gc* sessionType = 8;
        public: Int32 __gc* total = 0;
        public: Int32 __gc* userID = 0;
        public: Int32 __gc* userName = 2;
        public: String __gc* Usernames __gc [] = __gc new String __gc*[1];
        public: Int32 __gc* userType = 7;
    };
}

